﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;
using DevExpress.XtraBars.Localization;
namespace QLHS
{
    public partial class frm_Main : Form
    {
        //public static frm_Main Instance
        //{
        //    get
        //    {
        //        if (instance == null || instance.IsDisposed)
        //        {
        //            instance = new frm_Main();
        //        }
        //        return Instance;
        //    }
        //}
        public frm_Main()
        {
            InitializeComponent();
            SkinHelper.InitSkinGallery(RGB_giaodien, true);
        }
        public void load()
        {
            btndx.Enabled = false;
            btndshs.Enabled = false;
            btndslh.Enabled = false;
            btnhshs.Enabled = false;
            btnbhmh.Enabled = false;
            btndn.Enabled = true;
            btndoipass.Enabled = false;
            btntkm.Enabled = false;
            btntkhk.Enabled = false;
            btndsl.Enabled = false;
            btnmonhoc.Enabled = false;
        }
        frmLogin dangnhap;
        private void DangNhap()
        {
        //TiepTuc:
            if (dangnhap == null || dangnhap.IsDisposed)
            {
                dangnhap = new frmLogin();
                //dangnhap.Hide();
            }
            if (dangnhap.ShowDialog() == DialogResult.OK)
            {
                if(k!=0)
                    hienthi();
                //goto TiepTuc;
            }
        }
        private void btndn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DangNhap();
            //frmLogin f = new frmLogin();
            //f.Show();
            //Hide();
        }

        private void btndx_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            panelControl2.Controls.Clear();
            UCMain f = new UCMain();
            f.Dock = System.Windows.Forms.DockStyle.Fill;
            panelControl2.Controls.Add(f);
            load();
        }

        private void btnthoat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (MessageBox.Show("Bạn thật sự muốn thoát?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                Application.Exit();
            }
        }

        private void btnpb_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            panelControl2.Controls.Clear();
            UC_HoSoHS f = new UC_HoSoHS();
            f.Dock = System.Windows.Forms.DockStyle.Fill;
            panelControl2.Controls.Add(f);
        }

        private void btnnv_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            panelControl2.Controls.Clear();
            UCDanhSachLopHoc f = new UCDanhSachLopHoc();
            f.Dock = System.Windows.Forms.DockStyle.Fill;
            panelControl2.Controls.Add(f);
        }

        private void btntl_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            panelControl2.Controls.Clear();
            UCDanhSachHS f = new UCDanhSachHS();
            f.Dock = System.Windows.Forms.DockStyle.Fill;
            panelControl2.Controls.Add(f);
        }

        private void btntinhluong_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            panelControl2.Controls.Clear();
            UCDiemMon f = new UCDiemMon();
            f.Dock = System.Windows.Forms.DockStyle.Fill;
            panelControl2.Controls.Add(f);
        }

        private void btnungluong_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            panelControl2.Controls.Clear();
            UCTongKetMon f = new UCTongKetMon();
            f.Dock = System.Windows.Forms.DockStyle.Fill;
            panelControl2.Controls.Add(f);
        }

        private void btnkhen_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            panelControl2.Controls.Clear();
            UcTongKetHK f = new UcTongKetHK();
            f.Dock = System.Windows.Forms.DockStyle.Fill;
            panelControl2.Controls.Add(f);
        }

        private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            panelControl2.Controls.Clear();
            UCDanhSachLop f = new UCDanhSachLop();
            f.Dock = System.Windows.Forms.DockStyle.Fill;
            panelControl2.Controls.Add(f);
        }
        public static int k;
        public static string kt;
        private void frm_Main_Load(object sender, EventArgs e)
        {
            panelControl2.Controls.Clear();
            UCMain f = new UCMain();
            f.Dock = System.Windows.Forms.DockStyle.Fill;
            panelControl2.Controls.Add(f);
            load();
            //DangNhap();
            if (k != 0)
            {
                hienthi();
            }

        }
        public void hienthi()
        {
            btndn.Enabled = false;
            btndx.Enabled = true;
            btndshs.Enabled = true;
            btndslh.Enabled = true;
            btnhshs.Enabled = true;
            btndsl.Enabled = true;
            btnbhmh.Enabled = true;
            btndoipass.Enabled = true;
            btntkm.Enabled = true;
            btntkhk.Enabled = true;
            btnmonhoc.Enabled = true;
        }

        private void btndoipass_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frm_DoiPass f = new frm_DoiPass();
            f.Show();
        }

        private void btnmonhoc_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            panelControl2.Controls.Clear();
            UCMonHoc f = new UCMonHoc();
            f.Dock = System.Windows.Forms.DockStyle.Fill;
            panelControl2.Controls.Add(f);
        }
    }
}
